//
//  SplashLayer.cpp
//  Space shooting
//
//  Created by Raiden on 9/2/13.
//
//

#include "SplashLayer.h"
#include "StateManager.h"
#include "Constants.h"

using namespace cocos2d;

SplashLayer::SplashLayer() {
    
    init();
    
    runAction(CCSequence::create(CCDelayTime::create(1.0f), CCCallFunc::create(this, callfunc_selector(SplashLayer::nextScreen)), NULL));
}

SplashLayer::~SplashLayer() {
    removeAllChildrenWithCleanup(true);
}

bool SplashLayer::init() {
    
    if(!CCLayer::init()) {
        
        return false;
    }
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF *logo = CCLabelTTF::create("space ship", "Fonts/Spac3 neon.ttf", 40);
    logo->setColor(ccc3(255, 109, 1));
    
    logo->setPosition(ccp(size.width/2, size.height/2));
    
    addChild(logo);
    
    return true;
}

void SplashLayer::nextScreen() {
    
    StateManager::getInstance()->switchScene(GAME_STATE_HOME);
}